import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";

import axios from "axios";
import ElementUI from "element-ui";
import VueQuillEditor from "vue-quill-editor"
import "element-ui/lib/theme-chalk/index.css";
import TreeTable from 'vue-table-with-tree-grid'

axios.defaults.baseURL = "https://www.liulongbin.top:8888/api/private/v1/";
// axios请求拦截器
axios.interceptors.request.use(config => {
  config.headers.Authorization = window.sessionStorage.getItem("token");
  return config;
});
Vue.prototype.$ajax = axios;

// 引入字体图标库
import "assets/font/iconfont.css";
//富文本编辑器样式
import 'quill/dist/quill.snow.css'

Vue.config.productionTip = false;

Vue.use(ElementUI)
Vue.use(VueQuillEditor)
Vue.component("tree-table", TreeTable)

// 全局过滤器，格式化时间
Vue.filter("dateFormat", function (originVal) {
  const date = new Date(originVal)
  const y = date.getFullYear()
  const m = (date.getMonth() + 1 + "").padStart(2, "0") // 月份不足两位数的用0进行填充
  const d = (date.getDay() + "").padStart(2, "0")
  const hh = (date.getHours() + "").padStart(2, "0")
  const mm = (date.getMinutes() + "").padStart(2, "0")
  const ss = (date.getSeconds() + "").padStart(2, "0")

  return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
})

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount("#app");
